package game;

import math.Matrix4;
import renderer.CoordinatorRenderer;
import renderer.CrosshairRenderer;
import renderer2.WorldRenderer;
import sys.SysParam;
import world.Camera;
import world.Coordinator;
import world.Crosshair;
import world.World;

public class WorldManager {
	public static void renderCrosshair() {
		CrosshairRenderer.render(getInstance().crosshair);
	}

	public static void loadWorld() {
		getInstance().world.load();
	}

	public static void renderWorld() {
		(new WorldRenderer()).render(getInstance().world);
	}

	public static Matrix4 getWorldMatix() {
		return getInstance().world.matixStack.getTop();
	}

	public static Camera getCamera() {
		return getInstance().camera;
	}

	public static void renderCoordinator() {
		CoordinatorRenderer.render(getInstance().coordinator);
	}

	// ----------------------------------------------------------------private
	private static WorldManager instance;
	private World world;
	private Camera camera;
	private Crosshair crosshair;
	private Coordinator coordinator;	

	private static WorldManager getInstance() {
		if (instance == null) {
			instance = new WorldManager();
		}
		return instance;
	}

	private WorldManager() {
		init();
	}

	private void init() {
		crosshair = new Crosshair();
		world = new World();
		camera = new Camera(SysParam.FOV, SysParam.SCREEN_WIDTH, SysParam.SCREEN_HEIGHT, SysParam.ZNEAR, SysParam.ZFAR );
		world.addCamera(camera,SysParam.PlAYER_INIT_POSTION, SysParam.PlAYER_INIT_ORIENTATION);
		coordinator = new Coordinator(); 
	}
}
